perm filename MAP.PAL[AL,HE] blob
sn#193347 filedate 1975-12-16 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00005 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 Routines for use of the glorious Panofsky map with the
C00004 00003 BNCTAB, Macros
C00005 00004 Map definitions
C00007 00005 MAPINIT, SWITCH
C00010 ENDMK
C⊗;
COMMENT ⊗ Routines for use of the glorious Panofsky map with the
interpreter and AL runtime. This version requires that K2 be the
kernel. We take care of switching maps ourselves, but the kernel
sets up the mapping into four counties as follows:
0 27777 straight-through
30000 117777 mapped
120000 157777 straight-through
160000 177777 into I/O space
The mapped region, 30000:117777 is placed in physical locations
30000, 160000, 250000, and 340000 for counties 0, 1, 2, and 3,
respectively.
Calling a routine in a foreign county is done this way:
BOUNCE #LNAME ;Link name
The link name is an pointer into the link table. Each entry in that
table is two words. The first is the routine's address in that
county, and the second is the county number. The switch routine will
keep track of the stack and will set the return address to something
in itself. It handles the return and does all the necessary fixup. ⊗
; BNCTAB, Macros
LTAB: .BLKW 40 ;Enough for 20 links
BNCTAB:
II == BNCTAB ;
XX LALAID ;address
XX FOO ;county
. = II
.MACRO BOUNCE WALL
MOV WALL,-(SP) ;The link name of the routine
JSR PC,SWITCH ;A routine in common space to do it all
.ENDM
.MACRO EXTERNAL LAB,LLAB
LAB:
PUTLOC BNCTAB+LLAB,LAB ;The routine's address in that county
PUTLOC BNCTAB+LLAB+2,COUNTY ;The county.
.ENDM
.MACRO PLACE PHYS,VIRT
.OFFSET 0
.=PHYS
.OFFSET VIRT-PHYS
.ENDM
; Map definitions
;Page tables: 100 words each, one per page
MAPTB0=166000
MAPTB1=166200
MAPTB2=166400
MAPTB3=166600
;Page table entries (each one for 2000 bytes)
MAPWRT==100000 ;Page written
MAPACC==040000 ;Page accessed
MAPWOK==020000 ;Write permission
MAPROK==010000 ;Read permission
MAPUBS==004000 ;1 => Unibus address
; 003777 Physical page number
;Map space table
MAPKI=167020
MAPKD=167030
MAPSI=167022
MAPSD=167032
MAPUI=167026
MAPUD=167036
;Map space table entries
; 001400 Page table number
; 000200 Transparent mode ( 1 => no mapping)
; 000176 Max virtual page (*2)
MAPSR0=167000
;Status register 0 entries
MAPENB==100000 ;Enable mapping
MAPMPV==040000 ;Max page violation
MAPRPV==020000 ;Read violation
MAPWPV==010000 ;Write violation
; 30 ;PC mode of the violating instruction
; 04 ;Error was in I space
; 03 ;Mode of the violating reference
MAPSR1=167002 ;Virtual address of the bad reference
MAPSR2=167004 ;Virtual PC of 1st word of offending instruction
; MAPINIT, SWITCH
MAPINIT:
EVMAK ;Make a new mapping interlock event
MOV (SP),MAPEVT ;
EVSIG ;Give it one signal
MOV #SWSTCK,PTR ;Initialize the special stack
RTS PC ;
SWITCH:
COMMENT ⊗ The stack holds a pointer into the LTAB. Map exclusion is
kept throughout this routine to keep other processes from confusing
the special stack. This unfortunately prevents more than one switch
deep. Give some thought to resolving this problem, like giving a
process the capablility to do any number of switches, the capability
being restricted.
⊗
EVWAIT MAPEVT ;Enter critical region
MOV R0,-(SP) ;Save R0
MOV R1,-(SP) ;Save R1
MOV PTR,R1 ;The stack for this routine
MOV 4(SP),-(R1) ;Save the return address
MOV MAPUI,-(R1) ;Where we are coming from
MOV 6(SP),-(R1);Save the pointer into the LTAB
MOV (R1),R0 ;R0 ← pointer into LTAB
MOV 2(R0),R0 ;R0 ← desired county
ASH #10,R0 ;
ADD #176,R0 ;Maximum accessible page
MOV R0,MAPUI ;Set the instruction space
MOV R0,MAPUD ;Set the data space
MOV (R1)+,R0 ;R0 ← pointer into LTAB
MOV R1,PTR ;
MOV (R0),TEMP ;The address to jump to
MOV (SP)+,R1 ;Restore R1
MOV (SP)+,R0 ;Restore R0
TST (SP)+ ;Get rid of old return address
TST (SP)+ ;Get rid of the pointer to LTAB
JSR PC,@TEMP ;Jump to the routine, return here
MOV @PTR,MAPUI ;Go back to old space
MOV @PTR,MAPUD ;Go back to old space
ADD #2,PTR ;
MOV @PTR,-(SP) ;The return address
ADD #2,PTR ;
EVSIG MAPEVT ;End of critical region
RTS PC ;Return
TEMP: .BLKW 1 ;Variable in SWITCH
PTR: .BLKW 1 ;Variable in SWITCH
.BLKW 100 ;Stack used in SWITCH
SWSTCK: .BLKW 1 ;Top of stack